#!/bin/sh
# For Huawei E261 on mini6410
# By Leon from IIE

CONFIGFILE=/etc/3g-modem/12d1.1446.12d1.14ac
MODE=wcdma

while [ 1 ]
do

  #---------------------------------------------- 
 
  chat -v TIMEOUT 3 -f /etc/ppp/peers/chat-testmodem < /dev/ttyUSB0 > /dev/null 2>&1
  
  if [ $? -ne 0 ]; then
    echo "3g-modem -c /etc/3g-modem/12d1.1446.12d1.14ac -W"
    3g-modem -c ${CONFIGFILE} -W
  fi

  sleep 8
  
  #----------------------------------------------

  ifconfig ppp0 > /dev/null 2>&1
  
  if [ $? -ne 0 ]; then
    echo "pppd call wcdma"
    pppd call ${MODE} > /dev/null 2>&1 &
  fi

  sleep 8
  
  #----------------------------------------------

done
